package com.rv.exception;

import cn.dev33.satoken.exception.NotLoginException;
import com.rv.common.core.domain.R;
import com.rv.common.core.exception.ServiceException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author sundez
 * @version 1.1.3.9
 * @since 2025/7/17
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(NotLoginException.class)
    public R<Boolean> notLoginExceptionhandler(HttpServletRequest request, HttpServletResponse response, NotLoginException e) {
        return R.error("未查询到登录信息,请先登录");
    }

    @ExceptionHandler(ServiceException.class)
    public R<Boolean> serviceExceptionHandler(ServiceException e) {
        return R.error(e.getMessage());
    }
}